<?php
	include('sys.fun.php');
	$allowed = array('gif','jpef','jpg','png');
	$temp = explode(".",$_FILES['file']['name']);//explode:切开字符
	$estention = end($temp);
	if((($_FILES["file"]["type"] == "image/gif")
	||($_FILES["file"]["type"] == "image/jpeg")
	||($_FILES["file"]["type"] == "image/jpg")
	||($_FILES["file"]["type"] == "image/png"))
	&&($_FILES['file']['size']<204800)
	&&(in_array($estention,$allowed))){
		if($_FILES['file']['error']>0){
			echo '错误'.$_FILES['file']['error'];
		}else{
			echo '文件名：'.$_FILES['file']['name'].'<br/>';
			echo '文件类型：'.$_FILES['file']['type'].'<br/>';
			echo '文件大小：'.($_FILES['file']['size']/1024).'<br/>';
			echo '文件临时位置：'.$_FILES['file']['tmp_name'].'<br/>';
			
			if(file_exists("userfiles/".$_FILES['file']['name'])){
				echo $_FILES['file']['name'].'文件已存在';
			}else{
				move_uploaded_file($_FILES['file']['tmp_name'],"userfiles/".$_FILES['file']['name']);
			}
		}
	}else{
		echo $_FILES['file']['name'].'文件非法';
	}
	
?>